Preparativos

Carga de paquetes

library(readr)
library(dplyr)
library(tidyr)
library(ggplot2)
library(plotly)

Lectura de datos

bioestadisticas <-
  read_delim("bioestadisticas.csv")

Transformaciones

bioestadisticas <-
  bioestadisticas %>%
  mutate(fecha = as.Date(fecha, format = "%Y-%m-%d")) %>%
  arrange(fecha)

Análisis

Peso

Peso y grasa corporal

peso_grasa <-
  bioestadisticas %>%
  ggplot(aes(x = peso, y = `grasa-corporal`)) +
  geom_point(color = "red") +
  geom_smooth(method = "lm", se = TRUE, color = "black") +
  theme_minimal()

ggplotly(peso_grasa)
## Warning: Removed 4 rows containing non-finite values (stat_smooth).

Peso y masa muscular

peso_musculo <-
  bioestadisticas %>%
  ggplot(aes(x = peso, y = musculo)) +
  geom_point(color = "blue") +
  geom_smooth(method = "lm", se = FALSE, color = "black") +
  theme_minimal()

ggplotly(peso_musculo)
## Warning: Removed 5 rows containing non-finite values (stat_smooth).

Natación

Natación (distancia real) y peso

natacion_real_peso <-
  bioestadisticas %>%
  ggplot(aes(x = `nat-distancia-real`, y = peso)) +
  geom_point(color = "blue") +
  geom_smooth(method = "lm", se = FALSE, color = "black") +
  theme_minimal()

ggplotly(natacion_real_peso)
## Warning: Removed 113 rows containing non-finite values (stat_smooth).

Natación (distancia reloj) y peso

natacion_reloj_peso <-
  bioestadisticas %>%
  ggplot(aes(x = `nat-distancia-reloj`, y = peso)) +
  geom_point(color = "blue") +
  geom_smooth(method = "lm", se = FALSE, color = "black") +
  theme_minimal()

ggplotly(natacion_reloj_peso)
## Warning: Removed 113 rows containing non-finite values (stat_smooth).

Fecha

Fecha y peso

fecha_peso <-
  bioestadisticas %>%
  ggplot(aes(x = fecha, y = peso)) +
  geom_line(color = "blue") +
  geom_smooth(method = "gam", se = FALSE, color = "black") +
  geom_smooth(method = "loess", se = FALSE, color = "gray") +
  theme_minimal()

ggplotly(fecha_peso)
## Warning: Removed 4 rows containing non-finite values (stat_smooth).

## Warning: Removed 4 rows containing non-finite values (stat_smooth).

Fecha y grasa

fecha_grasa <-
  bioestadisticas %>%
  ggplot(aes(x = fecha, y = `grasa-corporal`)) +
  geom_line(color = "blue") +
  geom_smooth(method = "gam", se = FALSE, color = "black") +
  geom_smooth(method = "loess", se = FALSE, color = "gray") +
  theme_minimal()

ggplotly(fecha_grasa)
## Warning: Removed 4 rows containing non-finite values (stat_smooth).

## Warning: Removed 4 rows containing non-finite values (stat_smooth).

Fecha y músculo

fecha_musculo <-
  bioestadisticas %>%
  ggplot(aes(x = fecha, y = musculo)) +
  geom_line(color = "blue") +
  geom_smooth(method = "gam", se = FALSE, color = "black") +
  geom_smooth(method = "loess", se = FALSE, color = "gray") +
  theme_minimal()

ggplotly(fecha_musculo)
## Warning: Removed 5 rows containing non-finite values (stat_smooth).

## Warning: Removed 5 rows containing non-finite values (stat_smooth).

Fecha y natación

fecha_natacion <-
  bioestadisticas %>%
  filter(!is.na(`nat-distancia-real`) & !is.na(`nat-distancia-reloj`)) %>%
  ggplot() +
  geom_line(aes(x = fecha, y = `nat-distancia-real`), color = "blue") +
  geom_line(aes(x = fecha, y = `nat-distancia-reloj`), color = "red") +
  geom_smooth(
    aes(x = fecha, y = `nat-distancia-real`),
    method = "lm",
    se = FALSE,
    color = "blue"
  ) +
  geom_smooth(
    aes(x = fecha, y = `nat-distancia-reloj`),
    method = "lm",
    se = FALSE,
    color = "red"
  ) +  
  theme_minimal()

ggplotly(fecha_natacion)